

define(function(){
    
    var file = function () {
        this.link = document.createElement( 'a' );
        this.link.style.display = 'none';
        document.body.appendChild( this.link ); // Firefox workaround, see #6594
    };
    file.prototype.saveString = function ( text, filename ) {
        
        this.save( new Blob( [ text ], { type: 'text/plain' } ), filename );
        
    };
    
    file.prototype.save = function ( blob, filename ) {
        
        this.link.href = URL.createObjectURL( blob );
        this.link.download = filename || 'data.json';
        this.link.click();
        
        // URL.revokeObjectURL( url ); breaks Firefox...
        
    };
    
    file.prototype.upload = function (value,callback) {
        var render = new FileReader();
        render.readAsBinaryString (value);
        render.onload = function(e){
            var data = e.target.result;
            var dataArray = data.split("DATA");
            var ifcData = dataArray[1].split("ENDSEC");
            var object = ifcData[0].split(");");
            var text = JSON.stringify(screenData(object));
            if(callback)callback(text);
        };
    };
    return new file();
});